//
//  DTViewController.m
//  代号：47
//
//  Created by lanou3g on 15/7/10.
//  Copyright (c) 2015年 杨佩璋. All rights reserved.
//

#import "DTViewController.h"
#import <MAMapKit/MAMapKit.h>
#import <AMapSearchKit/AMapSearchAPI.h>
#define APIKey @"c0f24200f0ef6af9359df2356b92c38b"

@interface DTViewController ()<MAMapViewDelegate>

@property(nonatomic,retain)MAMapView *mapView;

@end

@implementation DTViewController

-(void)dealloc{
    
    _mapView = nil;
    [super dealloc];

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self initMapView];
}
-(void)initMapView{

    [MAMapServices sharedServices].apiKey = APIKey;
    self.mapView = [[[MAMapView alloc] initWithFrame:CGRectMake(0, 0, kScreen_width, kScreen_height)] autorelease];
    _mapView.delegate =self;
    [_mapView setZoomLevel:13.1 animated:YES];
    _mapView.logoCenter = CGPointMake(0 , 0);
    _mapView.compassOrigin = CGPointMake(kScreen_width - 50, kScreen_height - 50);
    _mapView.scaleOrigin = CGPointMake(10, kScreen_height - 50);
    _mapView.userTrackingMode = MAUserTrackingModeFollowWithHeading;
    
    [self.view addSubview:_mapView];
    [_mapView reloadInputViews];
    
    
    
    MAPointAnnotation *pointAnnotation = [[[MAPointAnnotation alloc] init] autorelease];
    pointAnnotation.coordinate = CLLocationCoordinate2DMake(_str1, _str2);
    [_mapView addAnnotation:pointAnnotation];
    [_mapView setCenterCoordinate:CLLocationCoordinate2DMake(_str1, _str2) animated:YES];
    

    
    _mapView.showsUserLocation = YES;
    _mapView.desiredAccuracy = kCLLocationAccuracyBest;//精度
    
    
    
    
    
    UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 30, kScreen_width, 30)] autorelease];
    view.backgroundColor = [UIColor grayColor];
    view.alpha = 0.3;
    [self.view addSubview:view];
    
    UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(50, 0, kScreen_width - 50, 30)] autorelease];
    label.text = @"很抱歉,本地图正在努力完善中...";
//    label.alpha = 0.3;
    
    [view addSubview:label];
    
    UIButton *button = [UIButton buttonWithType:(UIButtonTypeSystem)];
    button.backgroundColor = [UIColor blackColor];
    button.frame = CGRectMake(20, 0, 30, 30);
    [view addSubview:button];
    [button addTarget:self action:@selector(fanhui) forControlEvents:(UIControlEventTouchUpInside)];

    

}

-(void)fanhui{
    
[self dismissViewControllerAnimated:YES completion:^{
}];

}


-(void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation updatingLocation:(BOOL)updatingLocation{
    

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
